import pymysql

con = pymysql.connect(host='localhost', user='root', password='123456', database='1_test', port=3306,
                      charset='utf8', )
try:
    with con.cursor() as cursor:
        for i in range(10):
            a = i + 1
            print("请输入第%d个人的信息:" % a)
            username = input("请输入姓名：")
            age = int(input("请输入年龄："))
            sex = input("请输入性别：")
            high = int(input("请输入身高："))
            sql = "insert into person(username,age,sex,high) values (%s,%s,%s,%s)"
            cursor.execute(sql, (username, age, sex, high))
        con.commit()
finally:
    con.close()
print("存储成功！")
